package com.kaohe.service;

import java.util.List;

import com.kaohe.dao.CategoryDao;
import com.kaohe.domain.Category;
import com.kaohe.domain.PageBean;

public class CategoryService {

	private CategoryDao dao=new CategoryDao();
	//分页查询分类
	public PageBean<Category> cquery(PageBean<Category> pb) {
		
		//1.查询总条数
		int count =dao.count();
		//2.当前页的数据 limit 0,3;
		List<Category> result=dao.cquery(pb.getStartIndex(),pb.getPageSize());
		//封装
		pb.setResult(result);
		pb.setTotalRecord(count);
		return pb;
	}
	//添加
	public void addcategory(Category category) {
		dao.addcategory(category);
	}
	
	//修改-跳转到修改页面
	public Category toUpdateCategory(String cid) {
		
		Category cup = dao.toUpdateCategory(cid);
		return cup;
	}
	//修改-修改数据
	public void update(Category category) {
		dao.update(category);
	}
	public void decategory(String cid) {
		dao.decategory(cid);
	}
	

}

